// 格式化数据的方法
export function formateCityData(list) {
  let cityList = {};
  list.forEach((item) => {
    const first = item.first_letter; // 获取城市名称拼音首字母
    if (cityList[first]) {
      cityList[first].push(item);
    } else {
      cityList[first] = [item];
    }
  });
  // 按照26个英文字母排序并生成List
  cityList = Object.values(cityList).sort().sort((a,b) => a[0].first_letter.localeCompare(b[0].first_letter))
  // 对市/县/区进行排序
  cityList.forEach((obj) => {
    obj.sort((a, b) => {
      return a.first_letter - b.first_letter;
    });
  })
  const cityIndex = Object.keys(cityList).sort()
  return {
    cityList,
    cityIndex
  };
};
// 热门城市数据列表
export function getHotList() {
  const list = [
    {
      "_id": "66567c913d029c65e919fd3e",
      "code": "110000",
      "name": "北京",
      "pinyin": "beijingshi",
      "zip_code": "100000",
      "type": 0,
      "first_letter": "B"
    },
    {
      "_id": "66567c913d029c65e91a0058",
      "code": "310000",
      "name": "上海",
      "pinyin": "shanghaishi",
      "zip_code": "200000",
      "type": 0,
      "first_letter": "S"
    },
    {
      "_id": "66567c913d029c65e91a04d0",
      "code": "440100",
      "name": "广州市",
      "pinyin": "guangzhoushi",
      "zip_code": "510000",
      "parent_code": "440000",
      "parent_name": '广东',
      "type": 1,
      "first_letter": "G"
    },
    {
      "_id": "66567c913d029c65e91a04e7",
      "code": "440300",
      "name": "深圳市",
      "pinyin": "shenzhenshi",
      "zip_code": "518000",
      "parent_code": "440000",
      "parent_name": '广东',
      "type": 1,
      "first_letter": "S"
    },
    {
      "_id": "66567c913d029c65e91a00d9",
      "code": "330100",
      "name": "杭州市",
      "pinyin": "hangzhoushi",
      "zip_code": "310000",
      "parent_code": "330000",
      "parent_name": '浙江',
      "type": 1,
      "first_letter": "H"
    },
    {
      "_id": "66567c913d029c65e91a006b",
      "code": "320100",
      "name": "南京市",
      "pinyin": "nanjingshi",
      "zip_code": "210000",
      "parent_code": "320000",
      "parent_name": '江苏',
      "type": 1,
      "first_letter": "N"
    },
    {
      "_id": "66567c913d029c65e91a0091",
      "code": "320500",
      "name": "苏州市",
      "pinyin": "suzhoushi",
      "zip_code": "215000",
      "parent_code": "320000",
      "parent_name": '江苏',
      "type": 1,
      "first_letter": "S"
    },
    {
      "_id": "66567c913d029c65e919fd50",
      "code": "120000",
      "name": "天津",
      "pinyin": "tianjinshi",
      "zip_code": "300000",
      "type": 0,
      "first_letter": "T"
    },
    {
      "_id": "66567c913d029c65e91a03d1",
      "code": "420100",
      "name": "武汉市",
      "pinyin": "wuhanshi",
      "zip_code": "430000",
      "parent_code": "420000",
      "parent_name": '湖北',
      "type": 1,
      "first_letter": "W"
    },
    {
      "_id": "66567c913d029c65e91a0447",
      "code": "430100",
      "name": "长沙市",
      "pinyin": "changshashi",
      "zip_code": "410000",
      "parent_code": "430000",
      "parent_name": '湖南',
      "type": 1,
      "first_letter": "C"
    },
    {
      "_id": "66567c913d029c65e91a064f",
      "code": "500000",
      "name": "重庆",
      "pinyin": "chongqingshi",
      "zip_code": "400000",
      "type": 0,
      "first_letter": "C"
    },
    {
      "_id": "66567c913d029c65e91a0679",
      "code": "510100",
      "name": "成都市",
      "pinyin": "chengdushi",
      "zip_code": "610000",
      "parent_code": "510000",
      "parent_name": '四川',
      "type": 1,
      "first_letter": "C"
    },
  ]
  return list
}


